import { Component } from "react";


function Brother1({work}) {
  return(
    <div>
      <h2>兄弟1</h2>
      <p>公司： {work.name}</p>
      <p>工资： {work.money}</p>
    </div>
  )
}

function Brother2({work}) {
  return(
    <div>
      <h2>兄弟2</h2>
      <p>公司： {work.name}</p>
      <p>工资： {work.money}</p>
    </div>
  )
}

class Parent extends Component{
  state={
    // 状态提升，把兄弟组件都想要的放在父组件
    work:{
      name:'字节',
      money:15000
    }
  }
  render(){
    return(
      <div>
        <h1>父组件</h1>
        <hr />
        <Brother1 work={this.state.work}/>
        <Brother2 work={this.state.work}/>
      </div>
    )
  }
}

export default Parent